package org.itboys.seller.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.itboys.commons.utils.servlet.ServletContextHolder;
import org.itboys.seller.constant.SellerSessionConstant;

public class SellerSessionHolder {

	/**
	 * 获取登入这IP
	 * 
	 * @return
	 */
	public static String getLoginIp() {
		return ServletContextHolder.getRequest().getRemoteAddr();
	}

	/**
	 * 获取session中的用户ID
	 * @return
	 */
	public static final Long getSellerUserId(){
		return (Long) ServletContextHolder.getSession().getAttribute(SellerSessionConstant.SESSION_USER_ID);
	}
	
	/**
	 * 获取session中的商家ID
	 * @return
	 */
	public static final Long getSellerId(){
		return (Long) ServletContextHolder.getSession().getAttribute(SellerSessionConstant.SESSION_SELLER_ID);
	}
	
	/**
	 * 移除session中的用户ID
	 * @return
	 */
	public static final void removeSellerUserId(){
		 ServletContextHolder.getSession().removeAttribute(SellerSessionConstant.SESSION_USER_ID);
	}
	
	/**
	 * 获取Request
	 * @return
	 */
	public static final HttpServletRequest getRequest(){
		return ServletContextHolder.getRequest();
	}
	
	/**
	 * 获取Response
	 * @return
	 */
	public static final HttpServletResponse getResponse(){
		return ServletContextHolder.getResponse();
	}
}
